{% load staticfiles %}

<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
  <meta name="description" content="">
  <meta name="author" content="">
  <title>牟平区观水镇坟地防火预警系统</title>
  <link href="/static/css/bootstrap.min.css" rel="stylesheet">
  <link href="/static/css/sticky-footer-navbar.css" rel="stylesheet">
  <link href="/static/css/bootstrap-datetimepicker.css" rel="stylesheet">
</head>

<body>
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">牟平区观水镇坟地防火预警系统</a>
    </div>
    <div id="navbar" class="collapse navbar-collapse">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">首页</a></li>
        <li><a href="#">关于</a></li>
        <li><a href="/admin/">管理</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">菜单 <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="{% url 'django.contrib.auth.views.logout' %}">退出</a></li>
            <!--
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li class="dropdown-header">Nav header</li>
            <li><a href="#">Separated link</a></li>
            <li><a href="#">One more separated link</a></li>
            -->
          </ul>
        </li>
      </ul>
    </div><!--/.nav-collapse -->
  </div>
</nav>

<!-- Begin page content -->
<div class="container-fluid table-responsive">
  <form class="form-inline">
    <div class="form-group">
      <label for="village_list">村</label>
      <select class="form-control" id="village_list" name="village">
        <option value="all">全部</option>
      </select>
    </div>
    <div class="form-group">
      <label for="datetimeInputName">日期选择</label>
      <input class="form-control form_datetime" size="16" name="deaddate" type="text" id="datetimeInputName" value="" readonly>
    </div>
    <button type="submit" class="btn btn-primary">筛选</button>
  </form>
  <table class="table table-hover table-striped table-bordered text-nowrap">
      <thead><tr>
        <th>镇街</th>
        <th>村名</th>
        <th>死者姓名</th>
        <th>死亡时间</th>
        <th>烧头七时间</th>
        <th>烧二七时间</th>
        <th>烧三七时间</th>
        <th>烧四七时间</th>
        <th>烧五七时间</th>
        <th>烧六七时间</th>
        <th>烧七七时间</th>
        <th>烧百日时间</th>
        <th>烧周年时间</th>
        <th>烧二周年时间</th>
        <th>烧三周年时间</th>
        <th>主要亲属姓名</th>
        <th>联系电话</th>
        <th>备注</th>
    </tr></thead>
    <tbody>
    {% for dm in deadman_page %}
    <tr>
      <td>{{dm.deadman.village.town.name}}</td>
      <td>{{dm.deadman.village.name}}</td>
      <td>{{dm.deadman.deadman_name}}</td>
      <td>{{dm.sf_day.d0_d|date:"Y-m-d"}}<br>{{dm.sf_day.d0_ld}}</td>
      <td>{{dm.sf_day.d1_7_d|date:"Y-m-d"}}<br>{{dm.sf_day.d1_7_ld}}</td>
      <td>{{dm.sf_day.d2_7_d|date:"Y-m-d"}}<br>{{dm.sf_day.d2_7_ld}}</td>
      <td>{{dm.sf_day.d3_7_d|date:"Y-m-d"}}<br>{{dm.sf_day.d3_7_ld}}</td>
      <td>{{dm.sf_day.d4_7_d|date:"Y-m-d"}}<br>{{dm.sf_day.d4_7_ld}}</td>
      <td>{{dm.sf_day.d5_7_d|date:"Y-m-d"}}<br>{{dm.sf_day.d5_7_ld}}</td>
      <td>{{dm.sf_day.d6_7_d|date:"Y-m-d"}}<br>{{dm.sf_day.d6_7_ld}}</td>
      <td>{{dm.sf_day.d7_7_d|date:"Y-m-d"}}<br>{{dm.sf_day.d7_7_ld}}</td>
      <td>{{dm.sf_day.d100_d|date:"Y-m-d"}}<br>{{dm.sf_day.d100_ld}}</td>
      <td>{{dm.sf_day.y1_d|date:"Y-m-d"}}<br>{{dm.sf_day.y1_ld}}</td>
      <td>{{dm.sf_day.y2_d|date:"Y-m-d"}}<br>{{dm.sf_day.y2_ld}}</td>
      <td>{{dm.sf_day.y3_d|date:"Y-m-d"}}<br>{{dm.sf_day.y3_ld}}</td>
      <td>{{dm.deadman.kin_name}}</td>
      <td>{{dm.deadman.phone}}</td>
      <td>{{dm.deadman.memo}}</td>
    </tr>
    {% endfor %}
    </tbody>
  </table>
  <div class="pagination">
    <span class="step-links">
      {% if deadman_page.has_previous %}
      <a href="?page={{ deadman_page.previous_page_number }}&village={{village}}&deaddate={{deaddate}}">上一页</a>
      {% endif %}

      <span class="current">
        Page {{ deadman_page.number }} of {{ deadman_page.paginator.num_pages }}.
      </span>

      {% if deadman_page.has_next %}
      <a href="?page={{ deadman_page.next_page_number }}&village={{village}}&deaddate={{deaddate}}">下一页</a>
      {% endif %}
    </span>
  </div>
</div>

<footer class="footer">
  <div class="container-fluid">
    <p class="text-muted">牟平区观水镇森林防火指挥部</p>
  </div>
</footer>


<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/static/js/jquery-3.1.1.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="/static/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
function get_village() {
  $.ajax({
    type: "GET",
    url: "/dn/json/village/",
    async: false,
    dataType: "json",
    success: function (msg) {
      //$("#village_list").html('');
      $.each(msg, function(i, item) {
        $("#village_list").append('<option value="'+item+'">'+item+'</option>');
      });
    }
  });
}
$(document).ready(function() {
  get_village();
  console.log("ok");
  $(".form_datetime").datetimepicker({
      format: "yyyy-mm-dd",
      autoclose: true,
      startView: 2,
      minView: 2,
      todayBtn: true,
      language: 'zh-CN'
  });
});
</script>
</body></html>
